package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile     string `gorm:"type:varchar(30);not null"`
	Password   string `gorm:"type:varchar(32);not null"`
	HeadImage  string `gorm:"type:varchar(500)"`
	NickName   string `gorm:"type:varchar(32)"`
	Address    string `gorm:"type:varchar(50)"`
	WechatCode string `gorm:"type:varchar(100)"`
}

func (u *User) FindWechatByMobile(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).Find(u).Error
}

func (u *User) UserCreate(db *gorm.DB) error {
	return db.Debug().Create(u).Error
}

func (u *User) FindUserShow(db *gorm.DB, id string) error {
	return db.Debug().Where("id=?", id).First(u).Error
}

func (u *User) UserPerfect(db *gorm.DB) error {
	return db.Debug().Updates(u).Error
}
